﻿#include <iostream>
#include<string>
#include "AMRDef.h"

void vec1d_ph()
{
	std::cout << "Hello World!\n";
	int i[4] = { 11,12,13,14 };

	PHVector1D<int>a;
	PHVector1D<int>b(10);
	PHVector1D<int>c(10, 2);
	PHVector1D<int>d(i, i + 4);

	cout << "size of a = " << a.size() << endl;
	cout << "size of b = " << b.size() << endl;
	cout << "size of c = " << c.size() << endl;
	cout << "size of d = " << d.size() << endl;

	cout << "value of c = " << c[0] << endl;
	cout << "value of d = " << d[0] << endl;

	cout << d.GetPointer() << endl;

	PHVector2D<int>e;
	PHVector2D <int> f(10);
	cout << "size of e = " << e.size() << endl;
	cout << "size of f = " << f[0].size() << endl;
	cout << "=========================================" << endl;

};

void vec2d_c()
{
	int n = 5, m = 6;
	vector<vector<int> > obj(n); //定义二维动态数组大小5行 
	cout << obj.size() << endl;

	for (int i = 0; i < obj.size(); i++)//动态二维数组为5行6列，值全为0 
	{
		obj[i].resize(m);
		cout << obj[i].size() << endl;
	};

	for (int i = 0; i < obj.size(); i++)//输出二维动态数组 
	{
		for (int j = 0; j < obj[i].size(); j++)
		{
			obj[i][j] = i + j;
			cout << obj[i][j] << " ";
		}
		cout << "\n";
	};
	cout << "=========================================" << endl;
	vector<vector<int> > obj2(n, vector<int>(m));
	cout << obj2.size() << endl;
	for (int i = 0; i < obj2.size(); i++)//输出二维动态数组 
	{
		for (int j = 0; j < obj2[i].size(); j++)
		{
			obj2[i][j] = -(i + j);
			cout << obj2[i][j] << " ";
		}
		cout << "\n";
	};
	cout << "=========================================" << endl;
};

void vec2d_ph() 
{
	int n = 5, m = 6;
	PHVector2D<int> a(n);
	for (int i = 0; i < a.size(); i++)
	{
		a[i].resize(m);
	};

	for (int i = 0; i < a.size(); i++)//输出二维动态数组 
	{
		for (int j = 0; j < a[i].size(); j++)
		{
			a[i][j] = i + j;
			cout << a[i][j] << " ";
		}
		cout << "\n";
	};
	cout << "=========================================" << endl;

}

#define name2str(name) (#name)
template < typename T >
void print_value_add( const T *x ) 
{
	cout << "value "  << " = " << *x << endl;
	cout << "address " << " = " << x << endl;
};


void char_p_test() {

	int a = 10;
	double b = 2.5;
	unsigned char c = 'p';
	string d = "hello world";

	cout << name2str(a) << endl;
	print_value_add(&a);

	cout << name2str(b) << endl;
	print_value_add(&b);

	cout << name2str(c) << endl;
	print_value_add(&c);
	cout << &c << endl;

	cout << name2str(d) << endl;
	print_value_add(&d);

	char greeting[] = "Hello";
	cout << greeting << endl;
	cout << sizeof(greeting) / sizeof(greeting[0]) << endl;



};

void char_test() {
	const char * a = "string1";
	char b[] = "string1";

	cout << &("string1")<<endl;
	cout << &a << endl;
	cout << &b << endl;
	

	vector<char>::size_type pos;
	int posi = 0;
	pos = 0;
	cout << "pos = " <<pos<< endl;
	pos = pos + 2;
	cout << "pos = " << pos<< endl;
	cout << "size of pos = " << sizeof(pos) << endl;
	cout << "size of posi = " << sizeof(posi) << endl;
	
}

void vector_1th()
{
	vector <int> data(2, 1);
	cout << &(data) << endl;
	cout << &(data[0]) << endl;

	int dataa[2] = {1,1};
	cout << &(dataa) << endl;
	cout << &(dataa[0]) << endl;



};

int main() {
	//vec1d_ph();
	//vec2d_c();
	//vec2d_ph();
	//char_test();
	vector_1th();
};
